/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.pai;

import java.util.ArrayList;
import java.util.List;
import org.tempuri.ArrayOfPacjentPAI;
import org.tempuri.PacjentPAI;
import org.tempuri.WebServiceWyszukajPacjenta;

/**
 *
 * @author Grzegorz
 */
public class TestBean {
    
    private final String L = "admin";
    
    private final String P = "admin123";
    
    private String login;
    
    private String pesel;
    
    private String pass;
    
    private List<PacjentPAI> patients;

    public List<PacjentPAI> getPatients() {
        return patients;
    }

    public void setPatients(List<PacjentPAI> patients) {
        this.patients = patients;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }
    
    private WebServiceWyszukajPacjenta webService;
    
    public TestBean(){
        webService = new WebServiceWyszukajPacjenta();
        patients = new ArrayList<PacjentPAI>();
        login = "";
    }
    
    public String doSth(){
        ArrayOfPacjentPAI pacjenci = webService.getWebServiceWyszukajPacjentaSoap12().szukajPacjentaPesel(pesel);
        patients = pacjenci.getPacjentPAI();
        return "ok";
    }
    
    public String getLogin(){
        return login;
    }
    
    public void setLogin(String login){
        this.login = login;
    }

    public String getPesel() {
        return pesel;
    }

    public void setPesel(String pesel) {
        this.pesel = pesel;
    }
    
    public String logIn(){
        if (login.equals(L) && pass.equals(P)){
            return "/wczytywanie_pacjentow.xhtml";
        }
        if (!login.equals(L)){
            return "wrong login or password, please enter correct";
        }
        return "wrong password, please enter correct";
    }
    
    
    public String logOut(){
        login = "";
        pass = "";
        return "/index.xhtml";
    }
}
